﻿// Shader-Based-Image-Processing (SBIP)
// http://code.google.com/p/sbip/
//
// Copyright © Frank Nagl, 2009-2011
// admin@franknagl.de
//
namespace SBIP.Helper
{
    using System.Drawing;

    /// <summary>
    /// Container for float-channel (single) pixel including 2d .Net image 
    /// coordinate.
    /// </summary>
    public struct PixelFloat
    {
        /// <summary>X- and Y- image coordinate as <see cref="Point"/>.</summary>
        public Point Point { get { return new Point(X, Y); } }
        /// <summary>Reserved value,s with no direct function, can be used for 
        /// additional information.</summary>
        public float Reserved { get; set; }
        /// <summary>Float value.</summary>
        public float Value { get; set; }
        /// <summary>X-image coordinate.</summary>
        public int X { get; set; }
        /// <summary>Y-image coordinate.</summary>
        public int Y { get; set; }

        /// <summary>
        /// Implements the operator +.
        /// </summary>
        /// <param name="pixel">The original <see cref="PixelFloat"/>.</param>
        /// <param name="size">The size to move the coordinates.</param>
        /// <returns>The resulting <see cref="PixelFloat"/> with new coordinates.
        /// </returns>
        public static PixelFloat operator +(PixelFloat pixel, Size size)
        {
            return new PixelFloat
            {
                Value = pixel.Value,
                Reserved = pixel.Reserved,
                X = pixel.X + size.Width,
                Y = pixel.Y + size.Height
            };
        }

        /// <summary>
        /// Implements the operator -.
        /// </summary>
        /// <param name="pixel">The original <see cref="PixelFloat"/>.</param>
        /// <param name="size">The size to move the coordinates.</param>
        /// <returns>The resulting <see cref="PixelFloat"/> with new coordinates.
        /// </returns>
        public static PixelFloat operator -(PixelFloat pixel, Size size)
        {
            return new PixelFloat
            {
                Value = pixel.Value,
                Reserved = pixel.Reserved,
                X = pixel.X - size.Width,
                Y = pixel.Y - size.Height
            };
        }
    }
}